using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Viettel.VOFFICE.DAO.Models.Mapping
{
    public class v_ActionCollectionMap : EntityTypeConfiguration<v_ActionCollection>
    {
        public v_ActionCollectionMap()
        {
            // Primary Key
            this.HasKey(t => t.ActionId);

            // Properties
            this.Property(t => t.ActionName)
                .HasMaxLength(100);

            this.Property(t => t.ActionDisplayName)
                .HasMaxLength(255);

            // Table & Column Mappings
            this.ToTable("v_ActionCollection");
            this.Property(t => t.ActionId).HasColumnName("ActionId");
            this.Property(t => t.ActionName).HasColumnName("ActionName");
            this.Property(t => t.ActionDisplayName).HasColumnName("ActionDisplayName");
            this.Property(t => t.ControllerId).HasColumnName("ControllerId");
            this.Property(t => t.RequiredActionId).HasColumnName("RequiredActionId");

            // Relationships
            this.HasRequired(t => t.v_ControllerCollection)
                .WithMany(t => t.v_ActionCollection)
                .HasForeignKey(d => d.ControllerId);

        }
    }
}
